home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / mail / YAMscripts.lha / Tagline2.rexx < prev    next >
OS/2 REXX Batch file  |  1997-01-04  |  3KB  |  83 lines

  1. /*                        Tagline2.rexx
  2.                          v1.0 03-Jan-97
  3.  
  4.  -Copy this script to yam:rexx, edit the tagfile names and set the YAM editor to
  5.   'sys:rexxc/rx yam:rexx/tagline2.rexx' and you are ready to run!
  6.  -Pressing editor-button doesn't start external editor anymore, instead it adds
  7.   a tagline!
  8.  -Uses multiple tagline files to cut down the loading time, if you
  9.   have lots of taglines
  10.  -Tagfile should contain taglines separated by one separator line.  You
  11.   can define the separator yourself.
  12.  -If you wish to add empty lines before tagline, add NLs to the end of pretag
  13.  
  14.    As always comments and bug reports are welcomed at knikulai@utu.fi
  15. */
  16. options results
  17. parse arg message
  18. call addlib('rexxreqtools.library',0,-30)
  19. NL='0a'x            /* Newline */
  20.  
  21. /* 
  22. ** Change these values to your liking
  23. */
  24.   tagfiles=11            /* Number of tagfiles */
  25.   tagfile.1='packed:txt/taglines_1'  /* Their names */
  26.   tagfile.2='packed:txt/taglines_2'  
  27.   tagfile.3='packed:txt/taglines_3'  
  28.   tagfile.4='packed:txt/taglines_4'  
  29.   tagfile.5='packed:txt/taglines_5'  
  30.   tagfile.6='packed:txt/taglines_6'  
  31.   tagfile.7='packed:txt/taglines_7'  
  32.   tagfile.8='packed:txt/taglines_8'  
  33.   tagfile.9='packed:txt/taglines_9'  
  34.   tagfile.10='packed:txt/taglines_10'  
  35.   tagfile.11='packed:txt/taglines_11'  
  36.  
  37. separator='$'        /* This alone in a line means break between tags */
  38.    pretag=NL        /* Your Custom line to go before your tagline */
  39.  
  40.  
  41.  
  42. call random(,,time(s))          /* Let's make things really random */
  43.  
  44. /* let's first read all taglines */
  45. tc=1            /* How many tags are there? */
  46. tags.1=''       /* Set the first to empty */
  47. tagnum=random(1,tagfiles)              /* Select a tagfile */
  48. if open(in,tagfile.tagnum,'R') then do /* A tagfile was found */
  49.   do until eof(in)              /* Read everything in it */
  50.       rivi=readln(in)             /* Read one line */
  51.       if rivi=separator then do   /* If the line was separator line */
  52.             tc=tc+1               /* Next nonblank line will begin a new tag.. */
  53.             tags.tc=''            /* which will be empty first */
  54.          end
  55.       else                                /* The line was not a separator */
  56.          tags.tc=tags.tc || rivi || NL    /* Add it to the current tagline */
  57.       end /* do until eof*/
  58.   call close(1)                 /* Close tagfile */
  59.   end
  60. else do
  61.   address 'YAM' 'Request "Could not open ' ||tagfile.tagnum||'!" "OK"'
  62.   exit
  63.   end
  64.  
  65. if tags.tc='' then tc=tc-1 /* Let's just be sure there are no blanks... */
  66.  
  67. if open(out,message,'A') then do/* Open message file for appending */
  68.   i=rnd(tc)            /* Get a random number 1..tc */
  69.   if pretag~='' then
  70.         call writeln(out,pretag)/* Add customized line before Tagline */
  71.   call writeln(out,tags.i)    /* Write the tagline */
  72.   call close(out)        /* Close message file */
  73. end
  74. exit
  75.  
  76. rnd:
  77. /* random can't handle big numbers... This will create a big number and get
  78. ** modulo n+1.  This needs editing, if you have more than 30999 taglines... :-)
  79. */
  80.   parse arg n
  81.   r=1+(1000*random(1,30)+random(1,999))//n
  82. return r
  83.